package com.youku.wangheng.thinking.test;

import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import org.junit.Test;

public class ScheduledTestClazz {
	
	public static void main(String[] args) {
		ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(2);
		executor.scheduleAtFixedRate(new Thread1(), 1, 1, TimeUnit.SECONDS);
		executor.scheduleAtFixedRate(new Thread2(), 2, 2, TimeUnit.SECONDS);
		executor.scheduleAtFixedRate(new Thread3(), 3, 3, TimeUnit.SECONDS);
	}
	
	public static class Thread1 implements Runnable {

		public void run() {
			System.out.println("Thread1");
		}
		
	}
	
	public static class Thread2 implements Runnable {

		public void run() {
			System.out.println("Thread2");
		}
		
	}
	
	public static class Thread3 implements Runnable {

		public void run() {
			System.out.println("Thread3");
		}
		
	}
}
